package presistencia.conexao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class ConexaoImpl implements Conexao {
	private  final  static Connection conexao;
	private  final  static String connectionURL = "jdbc:mysql://mssql.antoniorafael.eti.br:3306/finn?user=finn&password=j8kl38sjhf0";

	static{
		Connection conexaoIn = null;
		
		try {	
			conexaoIn = DriverManager.getConnection(connectionURL);
		}		
		catch (SQLException e) {	
			e.printStackTrace();
		}
		conexao = conexaoIn;		
	}
	
	/* (non-Javadoc)
	 * @see presistencia.conexao.Conexao#getConnection()
	 */
	@Override
	public Connection getConnection(){
		return conexao;
	}
	
	/* (non-Javadoc)
	 * @see presistencia.conexao.Conexao#getPreparedStatement(java.lang.String)
	 */
	@Override
	public PreparedStatement getPreparedStatement(String statement) throws SQLException{
		PreparedStatement preparedStatement = null;
		
		preparedStatement = conexao.prepareStatement(statement,PreparedStatement.RETURN_GENERATED_KEYS);
		
		return preparedStatement;
	}
	
	
	
}
